import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-08-25
 * Time: 16:24
 */
public class demo3 {
    public static void main(String[] args) throws IOException {
        try(Reader reader = new FileReader("./test.txt")){
            while(true){
                char[] buffer = new char[1024];
                int n = reader.read(buffer);    //把从文件中读取的数据放在buffer数组中, 并且返回读取了多少个数据
                if(n == -1){    //文件内容已经被读取完成
                    break;
                }
                for(int i = 0; i < n; i++){
                    System.out.println(buffer[i]);
                }
            }
        }
    }
}
